package cn.cloud.project.provder.handler;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @ControllerAdvice + @ExceptionHandler 用于捕获 controller 出现的异常，但是转发失败、调用异常、转发失败这类的异常不是由controller抛出的所以无法捕获
 */
@ControllerAdvice
public class ConsoleExceptionHandler {

    @ExceptionHandler(Exception.class)
    private ResponseEntity<String> handleAccessException(Exception e) {
        return ResponseEntity.status(HttpStatus.FORBIDDEN).body(e.getMessage());
    }
}